﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using BanHangCshap.Class;
namespace BanHangCshap.Class
{
    class NoiDungThuChi:Database
    {
       
		#region ***** Fields & Properties ***** 
		private int _manoidungthuchi;
		public int manoidungthuchi
		{ 
			get 
			{ 
				return _manoidungthuchi;
			}
			set 
			{ 
				_manoidungthuchi = value;
			}
		}
		private string _tennoidungthuchi;
		public string tennoidungthuchi
		{ 
			get 
			{ 
				return _tennoidungthuchi;
			}
			set 
			{ 
				_tennoidungthuchi = value;
			}
		}
		private string _loainoidungthuchi;
		public string loainoidungthuchi
		{ 
			get 
			{ 
				return _loainoidungthuchi;
			}
			set 
			{ 
				_loainoidungthuchi = value;
			}
		}
		#endregion

		#region ***** Init Methods ***** 
		public NoiDungThuChi()
		{
		}
		public NoiDungThuChi(int manoidungthuchi)
		{
            string sql = "select * from NoiDungThuChi where manoidungthuchi = " + manoidungthuchi + "";
            foreach (DataRow dr in getDataTable(sql).Rows)
            {
                this.manoidungthuchi = manoidungthuchi;
                this.tennoidungthuchi = dr["tennoidungthuchi"].ToString().Trim();
                this.loainoidungthuchi = dr["loainoidungthuchi"].ToString().Trim();
            }
		}
		public NoiDungThuChi(int manoidungthuchi, string tennoidungthuchi, string loainoidungthuchi)
		{
			this.manoidungthuchi = manoidungthuchi;
			this.tennoidungthuchi = tennoidungthuchi;
			this.loainoidungthuchi = loainoidungthuchi;
		}
		#endregion
        public Boolean themNoiDungThuChi()
        {
            string sql = "insert into NoiDungThuChi(tennoidungthuchi, loainoidungthuchi) values (N'" + tennoidungthuchi + "', '" + loainoidungthuchi + "')";
            return executeQuery(sql);
        }
        public Boolean suaNoiDungThuChi(int manoidungthuchi)
        {
            string sql = "update NoiDungThuChi set tennoidungthuchi = N'" + tennoidungthuchi + "', loainoidungthuchi= '" + loainoidungthuchi + "' where manoidungthuchi = " + manoidungthuchi + "";
            return executeQuery(sql);
        }
        public Boolean xoaNoiDungThuChi(int manoidungthuchi)
        {
            string sql = "delete NoiDungThuChi where manoidungthuchi = " + manoidungthuchi + "";
            return executeQuery(sql);
        }
        public DataTable layDSNoiDungThuChi()
        {
            string sql = "select * from NoiDungThuChi";
            return getDataTable(sql); ;
        }
        public DataTable layDSNoiDungThuChiTheoLoai(string loainoidungthuchi)
        {
            string sql = "select * from NoiDungThuChi where loainoidungthuchi = '" + loainoidungthuchi + "'";
            return getDataTable(sql); ;
        }
        public DataTable layPhieuThuChi(int manoidungthudung)
        {
            string sql = "select mathuchi from PhieuThuChi where manoidungthuchi = " + manoidungthuchi + "";

            return getDataTable(sql); ;
        }

    }
}
